﻿using HKB.Common;
using HKB.Web;
using HKB.Web.Admin;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class Admin_Admin_InterfaceManage : Admin, IRequiresSessionState
{
    public string m_testurl;
    public string m_adminTestUrl;
    private InterfaceBll _interface = null;
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected InterfaceBll m_interface
    {
        get
        {
            InterfaceBll @interface;
            if (this._interface == null)
            {
                this._interface = new InterfaceBll(this.conn);
                @interface = this._interface;
            }
            else
            {
                @interface = this._interface;
            }
            return @interface;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.admin.CheckAdminPower(16))
        {
            base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "Interface");
            base.WriteRightErrMsg();
        }
        string str = this.config["SecurityKey"].ToString();
        string str2 = this.config["AdminSecurityKey"].ToString();
        string str3 = DateTime.Now.ToString("yyyyMMddHH");
        str = this.Md5("testabcdefghijklmnopqrstuvwxyz123456" + str + "Test" + str3, 32);
        this.m_testurl = "?action=Test&username=test&password=abcdefghijklmnopqrstuvwxyz123456&SecurityKey=" + str;
        str2 = this.Md5("testabcdefghijklmnopqrstuvwxyz123456" + str2 + "Test" + str3, 32);
        this.m_adminTestUrl = "?action=Test&username=test&password=abcdefghijklmnopqrstuvwxyz123456&SecurityKey=" + str2;
        this.GridView1.DataSource = this.m_interface.GetInterfaces();
        this.GridView1.DataBind();
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
        }
        if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Pager)
        {
            foreach (GridViewRow gridViewRow in this.GridView1.Rows)
            {
                Panel panel = (Panel)gridViewRow.FindControl("SetupSpan");
                LinkButton linkButton = (LinkButton)gridViewRow.FindControl("btnDelete");
                HtmlAnchor htmlAnchor = (HtmlAnchor)gridViewRow.Cells[10].FindControl("UpdateInterface");
                HiddenField hiddenField = (HiddenField)gridViewRow.Cells[10].FindControl("HiddenInterfaceID");
                htmlAnchor.Attributes.Add("onclick", " AddInterface('" + hiddenField.UniqueID + "','Modify');");
                if (!base.admin.CheckAdminPower(18))
                {
                    linkButton.Enabled = false;
                }
                if (!base.admin.CheckAdminPower(17))
                {
                    panel.Visible = false;
                }
            }
        }
    }
    protected void btnDelete_Command(object sender, CommandEventArgs e)
    {
        this.m_interface.DelInterface(int.Parse(e.CommandName));
        this.GridView1.DataSource = this.m_interface.GetInterfaces();
        this.GridView1.DataBind();
    }
}
